package JavaEE_notes.common_API.Thread.pojo;

/**
 * @author TaiZai
 * @data 2024/9/24 11:44
 */
public class MyThread extends Thread  {

    public MyThread() {}

    public MyThread(String name) {
        super(name); // 执行父类 Thread(String name)构造器，为当前线程设置名字
    }

    @Override
    public void run() {
        // currentThread() 获取当前线程的引用，哪个线程执行它，它就会得到哪个线程对象
        Thread t = Thread.currentThread();
        for (int i = 0; i < 3; i++) {
            // getName() 获取线程的名称
            System.out.println(t.getName() + "输出了" + i);
        }
    }
}
